//公共
const path =require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports={
    entry: './main.js',
    output: {
        //将所有的依赖模块输入到bundle.js
        filename: "bundle.js",
        //将输出文件放到dist文件夹下
        path: path.resolve(__dirname,'./dist')
    },
    module: {
        rules: [
            {
                //用正则表达式去匹配要用该Loader转换的css文件
                test: /\.css$/,
                use:['style-loader','css-loader'],
            },
            {
                //处理scss文件
                test: /\.(scss|sass)$/,
                use: ['style-loader','css-loader','sass-loader'],
            },
            {
                test: /\.js$/,
                use: {
                    loader: 'babel-loader',
                },
                exclude: /node_modules/   // 排除匹配node_modules模块
            }
        ]
    },
    plugins: [
        new webpack.BannerPlugin('版权所有'),
        new HtmlWebpackPlugin({
            template: path.join(__dirname, "/src/index.template.html")// new一个这个插件的实例，并传入相关的参数
        }),
        new webpack.HotModuleReplacementPlugin(),
    ]
}